<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>05-js中的数据类型转换</title>
</head>
<body>
<script>
    /*
        强制类型转换 Number() String() Boolean()
     */
    var a="10";
    console.log(Number(a));
    console.log(typeof Number(a));
    var b=100;
    console.log(String(b));
    console.log(typeof String(b));
    var c=1; // 0,-0,0.0,-0.0,"",都是false
    console.log(Boolean(c));
    console.log(typeof Boolean(c));

</script>

<script>
    /*
        自动类型转换

     */
    /*
        1.number 转 string
     */
    var a=10;
    console.log(a + "");
    console.log(typeof (a + ""));
    /*
        2.string 转 number
     */
    var b="10";
    console.log(b - 1);
    console.log(typeof (b - 1));
    /*
        3.boolean 转 number  false 为 0 true 为 1
     */
    var c=true;
    console.log(c + 1);
    console.log(typeof (c + 1));
</script>
</body>
</html>